1. Field of the Invention
The present invention relates to an image data compression method and an image data compression device.
2. Description of the Prior Art
In general, a printing apparatus such as a printer or multi-function peripherals (MFP) is equipped with a memory for storing image data to be printed. The printing apparatus starts printing job after the image data that is generated by a personal computer or the like is stored in the memory for usually at least one page (corresponding to approximately 100 megabytes in an uncompressed state).
In consideration of recent requirement for high image quality, data size (data quantity) of an image that is used for printing has a tendency of increasing enormously. If the image data size increases, it is necessary to increase capacity of a memory (memory capacity) that is provided to the printing apparatus so that the increase of the image data size is supported. This will cause an increase in cost. Therefore, it is desirable to reduce the required memory capacity by decreasing the image data size.
Conventionally, various compression techniques have been used for reducing image data size. Among them, there is known JPEG as a typical one. JPEG is one of compression formats of still image data, and it can realize high compression ratio by allowing generation of some deterioration in image quality (by discarding a part of data) when the compression is performed.
However, in a general compression method such as JPEG, the compression ratio varies depending on the image data. Therefore, if the memory capacity of the printing apparatus is reduced based on expectation that the data quantity after the compression becomes small, the data quantity may exceed the memory capacity. If the data quantity exceeds the memory capacity, the printing cannot be performed.
In order to avoid such a situation, it is necessary that the memory has sufficient capacity. Then, however, the memory capacity cannot be reduced after all. In this case, furthermore, the memory that is used should have capacity that can support the case where the compression ratio is the least. Therefore, data quantity after the compression becomes much smaller than the memory capacity in most cases, so there will be excessive memory area as waste. In the case of a printing apparatus that is capable of double side printing, the memory capacity is required to be sufficient for storing image data of at least two pages. If the printing apparatus has a function of sorting, the memory capacity is required to be sufficient for storing image data corresponding to maximum pages that can be sorted. In this printing apparatus, the above-mentioned excessive memory area as waste will further increase. In order to solve this problem, following methods are proposed.
Japanese unexamined patent publication No. 2001-238085 discloses a method in which an image processing apparatus reads an original, and image data of the read original is compressed. An appropriate compression parameter is selected based on the compressed image data. The data is compressed again by using the selected compression parameter so as to generate compressed data.
Japanese unexamined patent publication No. 2005-252573 discloses a method in which an image processing apparatus stores image data in a main memory. Coding is performed based on the stored image data at a plurality of quantization levels. Then, a code length is determined based on the plurality of quantization levels, so as to determine a quantization value that satisfies a target code length and is an optimal quantization value.
Japanese unexamined patent publication No. 2003-69835 discloses a method in which image data is coded with a first coding parameter. If it is decided that coded result will exceed a predetermined size during the coding process, the compression process is switched to use a second coding parameter having higher compression ratio. The part that is already coded with the first coding parameter is decoded and then coded again with the second coding parameter.
By using these compression methods, it is possible to perform compression that is suitable for memory capacity of the printing apparatus, so that the above-mentioned problem can be solved.
However, according to the method of Japanese unexamined patent publication No. 2001-238085 and the method of Japanese unexamined patent publication No. 2005-252573, an experimental compression process has to be performed a plurality of times in order to determine an optimal compression parameter for generating compressed data. Therefore, its process efficiency is lowered.
In addition, the image data to be compressed has to be kept in a memory after being read first time until the compressed data is generated finally or has to be reread every time when the compression process is performed. In the case where the image data is kept in the memory, an additional memory area for its purpose is necessary besides the memory area that is used for the compression process when the compression parameter is determined. Usually, image data has large data quantity, so keeping the image data can be a large load on an apparatus that performs compression. If the memory is occupied, other processes of the apparatus may be troubled. Although it is possible to save the image data in a place except the memory for securing the memory area, process speed may be lowered in that case because swapping occurs every time when the compression process is performed.
In the case where the image data is reread when the compression process is performed, the entire process may be largely delayed because the reading process may take a long time.
In the method described in Japanese unexamined patent publication No. 2003-69835, if the compression process is started with setting of a compression parameter that causes little loss of information quantity in the compression process, i.e., a compression parameter having a low compression ratio, there may be the case frequently where data quantity after the compression exceeds target data quantity. In this case, the compressed image data should be expanded once and be compressed again, so that process time will be increased largely.
On the contrary, if the compression process is started with setting of a compression parameter that causes a lot of loss of information quantity in the compression process, i.e., a compression parameter having a high compression ratio, a lot of information may be discarded needlessly so that unnecessary deterioration in image quality may be caused. Therefore, it is difficult to achieve both optimization of image quality and an increase of process speed.